var isChaseNum = false;
$(function() {
	$("#btnChaseNum").click(ChaseNum);
	$("#btnClear").click(function(a) {
		$(".btn-group a").removeClass("chengse")
	});
	$(".js-iptBet").focus(function() {
		$(this).val("")
	});
	$(".js-iptBet").change(function() {
		if ($(this).val() == "") $(this).val("0");
		$(this).val(parseInt($(this).val() * 1 / 100) * 100)
	});
	$(".js-fastbet").click(function() {
		if ($(this).attr("onclick") != "") {
			return
		}
		var b = $(this).data("money");
		var c = $(".js-img-check").siblings(".fr").find("input");
		var d = 0;
		var e = 0;
		if (c.attr("id") == "iptz") d = b;
		else e = b;
		$.ajax({
			url: "/Uc/SubmitBet?" + Math.random(),
			type: "post",
			dataType: "json",
			data: {
				issueNum: curIssue.IssueNum,
				hongtl: d,
				DFW: e,
				huitl: 0,
				myy: 0
			},
			success: function(a) {
				if (!a.success) {
					$.messager.alert("警告", a.msg, "warning");
					GetUserInfo();
					if (a.msg == "您已在别处登录！") setTimeout('window.location.href = "/Home"', 2000)
				} else {
					$("#iptz").val(a.list.zBet);
					$("#iptf").val(a.list.fBet);
					$(".js-djmoney").html("冻结：" + (a.list.zBet * 1 + a.list.fBet * 1));
					GetUserInfo();
					GetAllBet(true)
				}
			},
			error: function() {
				$.messager.alert("警告", "参数错误！", "warning")
			}
		})
	})
});

function ChaseNum(a) {
	if (a.target.innerText == "我要追号") {
		if ($(".btn-group").find("a.chengse").length < 1) {
			$.messager.alert("提示", "请选择投注内容！");
			return
		}
		var b = ($(window).height() - $('#dlg').outerHeight()) / 2 + document.body.scrollTop;
		$('#dlg').window('open').window('resize', {
			top: b
		});
		$("#ChaseNumCount").change()
	} else {
		isChaseNum = false;
		$("[name='DivChaseNum']").hide(500);
		a.target.innerText = "我要追号"
	}
}
function ShowBetConfig(b) {
	isChaseNum = b;
	var c = "";
	var d = "";
	var e = "";
	var f = 1;
	var g = 1;
	var h = 0;
	var j = false;
	var k = false;
	var l = BetBase;
	var m = $("#iptz").val() == "" ? "0" : $("#iptz").val();
	var n = $("#iptf").val() == "" ? "0" : $("#iptf").val();
	var o = /^(\d+)(\.\d{1,2})?$/;
	if (!o.test(m) || m < 0 || (m > 0 & m < minBet) || m > maxBet) {
		$.messager.alert("提示", "正面投注金额有误，最低投注" + minBet + "最高投注" + maxBet + "！");
		return
	}
	if (!o.test(n) || n < 0 || (n > 0 & n < minBet) || n > maxBet) {
		$.messager.alert("提示", "反面投注金额有误，最低投注" + minBet + "最高投注" + maxBet + "！");
		return
	}
	if (m == 0 && n == 0) {
		$.messager.alert("提示", "请填写投注金额！");
		return
	}
	if (isChaseNum) {
		g = "";
		for (var i = 1; i <= GetChaseCount(); i++) {
			g += $("#ChaseBS" + i).val() + ",";
			h += $("#ChaseBS" + i).val() * f * l
		}
		g = g.substr(0, g.length - 1)
	} else h = l * (m * 1 + n * 1);
	$.ajax({
		url: "/Uc/SubmitBet?" + Math.random(),
		type: "post",
		dataType: "json",
		data: {
			issueNum: curIssue.IssueNum,
			hongtl: m,
			DFW: n,
			huitl: 0,
			myy: 0
		},
		success: function(a) {
			if (!a.success) {
				$.messager.alert("警告", a.msg, "warning");
				GetUserInfo();
				if (a.msg == "您已在别处登录！") setTimeout('window.location.href = "/Home"', 2000)
			} else {
				$("#iptz").val(a.list.zBet);
				$("#iptf").val(a.list.fBet);
				$(".js-djmoney").html("冻结：" + (a.list.zBet * 1 + a.list.fBet * 1));
				GetUserInfo();
				GetAllBet(true)
			}
		},
		error: function() {
			$.messager.alert("警告", "参数错误！", "warning")
		}
	})
}
function GetChaseCount() {
	if (!isChaseNum) return 1;
	return $("#ChaseNumCount").val()
}